//
//  RegiseterTwoViewController.m
//  1243
//
//  Created by ym on 16/4/21.
//  Copyright © 2016年 1243. All rights reserved.
//

#import "RegiseterTwoViewController.h"
#import "NetWorkTools.h"
@interface RegiseterTwoViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *shouHuoRenPhoneNumTextField;

@property (weak, nonatomic) IBOutlet UITextField *shouHuoRenAddressTextField;
@property (weak, nonatomic) IBOutlet UITextField *tuiJianMaNumberTextField;
@property (weak, nonatomic) IBOutlet UITextField *shouHuoRenNameTextField;
@property (weak, nonatomic) IBOutlet UITextField *kaiHuBankTextField;
@property (weak, nonatomic) IBOutlet UITextField *inPutBankNumberTextField;
@property (weak, nonatomic) IBOutlet UITextField *kaiHuHangBankTextField;

@end

@implementation RegiseterTwoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationController.navigationBar.translucent = NO;
    
    self.shouHuoRenPhoneNumTextField.delegate = self;
    self.shouHuoRenPhoneNumTextField.tag = 101;
    
    self.shouHuoRenAddressTextField.delegate = self;
    self.shouHuoRenAddressTextField.tag = 100;
    
    self.tuiJianMaNumberTextField.delegate = self;
    self.tuiJianMaNumberTextField.tag = 101;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {

    [self resignFirstResponderTextField];
}

- (void)resignFirstResponderTextField {
    [self.shouHuoRenAddressTextField resignFirstResponder];
    [self.shouHuoRenPhoneNumTextField resignFirstResponder];
    [self.tuiJianMaNumberTextField resignFirstResponder];
    [self.shouHuoRenNameTextField resignFirstResponder];
    [self.kaiHuBankTextField resignFirstResponder];
    [self.inPutBankNumberTextField resignFirstResponder];
    [self.kaiHuHangBankTextField resignFirstResponder];
}

- (IBAction)ZhuCe:(id)sender {
    
    [[NetWorkTools sharedNetWorkTools] objectWithURLDict:self.dic AndMenthodName:@"ADDUSER" completeBlock:^(id object) {
        NSLog(@"%@",object);
        
        NSString *string = [object objectForKey:@"Message"];
        
        string = [string stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:string delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
       
        
        [alert show];
        
        if ([object[@"Id"] integerValue] == 0) {
            [self dismissViewControllerAnimated:YES completion:nil];
        }
        
    }];
    
}

-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    if (textField.tag == 101|| textField.tag == 100) {
        CGRect frame = textField.frame;
        int offset = frame.origin.y + 80 - (self.view.frame.size.height - 216.0);//键盘高度216
        
        //将视图的Y坐标向上移动offset个单位，以使下面腾出地方用于软键盘的显示
        if(offset > 0)
            self.view.frame = CGRectMake(0.0f, -offset, self.view.frame.size.width, self.view.frame.size.height);
        
        [UIView commitAnimations];
        
    }
}

-(void)textFieldDidEndEditing:(UITextField *)textField
{
    CGFloat width = [UIScreen mainScreen].bounds.size.width;
    CGFloat height = [UIScreen mainScreen].bounds.size.height;
    
    self.view.frame =CGRectMake(0, 64, width, height);
    //    NSLog(@"%@", textField.text);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
